package vsvm.graphics.charts;

import java.awt.Color;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.Iterator;

import vsvm.classifier.AbstractTestSet;
import vsvm.classifier.TestCase;
import vsvm.data.model.AbstractAttribute;
import vsvm.math.Point;
import vsvm.math.statistics.ROCAnalysis;

public class ROCChart extends AbstractChart{
	private static final long serialVersionUID = 100L;
	
	private ROCAnalysis roc = null;
	
	
	public ROCChart(String title, ROCAnalysis roc) {
		super(title);		
		this.roc = roc;
	}
	
	
	protected Graphics2D drawChart(Graphics2D g) {
		return g;
	}	
	
	
	protected void prepareColors() {
		this.setColors(new Color[]{Color.GREEN, Color.RED, Color.BLUE});
	}
	
	private void prepareData(){		
		
		Iterator <Point> curve = roc.getROCCurve();		
		
		while(curve.hasNext()) {
			Point p = curve.next();
			this.addPoint(1, p.x, p.y, true);
		}		
		
		this.addPoint(0, roc.getClassifierPoint().x, roc.getClassifierPoint().y, false);
		
		this.setMarksStyle("dots", 0);
		
	}	
	
	
	protected void prepareChart() {
		prepareData();
		this.addPoint(2, 0, 0, true);
		this.addPoint(2, 1, 1, true);	
		
		chartPrepared = true;
	}	
}
